package mipo.top.shop.controller;

import mipo.top.base.util.JsonResult;
import mipo.top.base.util.PageUtil;
import mipo.top.shop.domain.SearchMasterMsgAuditLog;
import mipo.top.shop.query.SearchMasterMsgAuditLogQuery;
import mipo.top.shop.service.ISearchMasterMsgAuditLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/searchMasterMsgAuditLog")
public class SearchMasterMsgAuditLogController {

    @Autowired
    private ISearchMasterMsgAuditLogService searchMasterMsgAuditLogService;

    @GetMapping
    public List<SearchMasterMsgAuditLog> sad(){
        return searchMasterMsgAuditLogService.findall();
    }

    @PutMapping
    public JsonResult su(@RequestBody SearchMasterMsgAuditLog searchMasterMsgAuditLog){
        try {
            if(searchMasterMsgAuditLog.getId()==null){
                searchMasterMsgAuditLogService.save(searchMasterMsgAuditLog);
            }else{
                searchMasterMsgAuditLogService.update(searchMasterMsgAuditLog);
            }
            return JsonResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.me().setMsg("错误数据");
        }
    }

    @DeleteMapping("/{id}")
    public void adw(@PathVariable("id") Long id){
        searchMasterMsgAuditLogService.remove(id);
    }

    @PostMapping
    public PageUtil<SearchMasterMsgAuditLog> asp(@RequestBody SearchMasterMsgAuditLogQuery searchMasterMsgAuditLogQuery){
        return searchMasterMsgAuditLogService.queryData(searchMasterMsgAuditLogQuery);
    }
    @PatchMapping
    private void bacthDel(@RequestBody List<Long> ids){
        searchMasterMsgAuditLogService.patchremove(ids);
    }

}